using UnityEngine;

public class ExplosiveDevice : MonoBehaviour
{
	public Collider2D trigger;

	public Tool tool;

	public GameObject explosion;

	public int contactCount;

	public float delay;

	public bool actived;

	public GameObject triggerObject;

	private void Start()
	{
		trigger.enabled = false;
	}

	private void FixedUpdate()
	{
		if (tool.placed && !trigger.enabled)
		{
			trigger.enabled = true;
		}
		if (contactCount > 0 && !tool.onPlace && !actived)
		{
			actived = true;
			trigger.enabled = false;
			triggerObject.SetActive(value: true);
			Invoke("Explosion", delay);
		}
	}

	public void Explosion()
	{
		explosion.SetActive(value: true);
		tool.Die();
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (collision.tag == "Zombie")
		{
			contactCount++;
		}
	}

	private void OnTriggerExit2D(Collider2D collision)
	{
		if (collision.tag == "Zombie")
		{
			contactCount--;
		}
	}
}
